package com.truongnha.clienttn.data.dao;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

public class TeacherAttendDAO {
	private final SQLiteDatabase db;

	public TeacherAttendDAO(SQLiteDatabase db) {
		super();
		this.db = db;
	}

	public long insert(String data, int classId, int day, int month, int year) {
		ContentValues inititalValue = new ContentValues();
		inititalValue.put(TeacherAttendScheme.DATA, data);
		inititalValue.put(TeacherAttendScheme.CLASS_ID, classId);
		inititalValue.put(TeacherAttendScheme.DAY, day);
		inititalValue.put(TeacherAttendScheme.MONTH, month);
		inititalValue.put(TeacherAttendScheme.YEAR, year);
		return db.insert(TeacherAttendScheme.TABLE_NAME, null, inititalValue);
	}

	public void delete() {
		db.delete(TeacherAttendScheme.TABLE_NAME, null, null);
	}

	public String get(int classId, int day, int month, int year) {
		Log.d("LOG", "step 3.3.1");
		String sql = "SELECT * from " + TeacherAttendScheme.TABLE_NAME;
		// sql += " where class_id = " + classId + " and day = " + day
		// + " and month = " + month + " and year = " + year;
		Cursor mcursor = db.rawQuery(sql, null);

		mcursor.moveToFirst();
		String temp = mcursor.getString(1);
		mcursor.close();
		return temp;
	}

}
